#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    printf("我的程序要运行了！\n");

    if (fork() == 0)
    {
        printf("I am Child, My Pid Is: %d\n", getpid());
        sleep(1);

        char *const argv[] = {
            (char *const)"echo",
            (char *const)"这是execvp替换的输出",
            NULL
        };
        
        // int execvp(const char *file, char *const argv[]);
        execvp("echo", argv);

        exit(1);
    }

    waitpid(-1, NULL, 0);
    printf("我的程序运行完毕了\n");
    return 0;
}
